package com.ruoyi.web.controller.cems;

import com.ruoyi.cems.domain.BmsEmergencyVariableControl;
import com.ruoyi.cems.domain.BmsWorkChecklists;
import com.ruoyi.cems.domain.dto.BmsEmergencyVariableControlDTO;
import com.ruoyi.cems.service.IBmsEmergencyVariableControlService;
import com.ruoyi.cems.service.IBmsWorkChecklistsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description="个人工作台接口")
@RestController
@RequestMapping("/cems/pwc")
public class BmsPersonalWorkbenchController extends BaseController {

    @Autowired
    private IBmsEmergencyVariableControlService bmsEmergencyVariableControlService;
    @Autowired
    private IBmsWorkChecklistsService bmsWorkChecklistsService;
    @ApiOperation("与我相关的控制表")
    @GetMapping("/getMyVariableControls")
    public AjaxResult getMyVariableControls(){
        BmsEmergencyVariableControlDTO bevcDto = new BmsEmergencyVariableControlDTO();

//        if(!SecurityUtils.hasRole("manager")){
//            //数据权限:普通用户：仅自己
            bevcDto.setManager(false);
            bevcDto.setUserId(getUserId().toString());
//        }else {
//            bevcDto.setManager(true);
//        }
        bevcDto.setStatus(2);
        bevcDto.setUnitCode(getLoginUser().getUser().getUnit());
        List<BmsEmergencyVariableControl> list = bmsEmergencyVariableControlService.selectBmsEmergencyVariableControlList(bevcDto);
        return AjaxResult.success(list);
    }
    /**
     * 查询工作检查单列表
     */
    @ApiOperation(value = "未处理应急通知")
    @GetMapping("/getMyWorkChecklists")
    public AjaxResult getMyWorkChecklists()
    {
        BmsWorkChecklists bmsWorkChecklists = new BmsWorkChecklists();
//        if(!SecurityUtils.hasRole("manager")){
            //数据权限:普通用户：仅自己
            bmsWorkChecklists.setCheckPeopleId(getUserId().toString());
//        }

        bmsWorkChecklists.setStatus("新建");
        bmsWorkChecklists.setEnId("1");
        bmsWorkChecklists.setUnitCode(getLoginUser().getUser().getUnit());
        bmsWorkChecklists.setPersonalWork(true);
        List<BmsWorkChecklists> list = bmsWorkChecklistsService.selectBmsWorkChecklistsList(bmsWorkChecklists);
        return AjaxResult.success(list);
    }
}
